package cn.tuling.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * Created on 2020/12/2.
 *
 * @author qiyang.
 * 描述：
 */
public class MyInvocationHandler implements InvocationHandler {

    private Object target;

    public MyInvocationHandler(Object obj) {
        this.target = obj;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("1.前置逻辑：args = " + Arrays.asList(args));

        Object result = method.invoke(target, args);

        System.out.println("3.后置逻辑：" + result);

        return result;
    }
}
